// Copyright (c) 2007 Robin Boerdijk. All rights reserved.
//
// This software is licensed under the terms of the Microsoft Reciprocal License as described 
// in the file LICENSE.txt, which you should have received as part of this distribution. The 
// license terms are also available at http://www.opensource.org/licenses/ms-rl.html.

#include "wtkpc.h"

#include "wtk/ContainerBox.h"
#include "wtk/ControlBox.h"
#include "wtk/FillerBox.h"
#include "wtk/GridBox.h"

namespace wtk
{
	ContainerBox::ContainerBox(Count initialCapacity)
		: m_boxes()
	{
		m_boxes.reserve(initialCapacity);
	}

	ContainerBox::~ContainerBox()
	{
		for (Count i = 0, n = m_boxes.size(); i < n; i++) {
			Box *box = m_boxes[i];
			if (box != NULL) {
				delete box;
			}
		}
	}

	ControlBox *ContainerBox::AddControlBox(Control &control, long horizontalElasticity, long verticalElasticity)
	{
		return Add(new ControlBox(control, horizontalElasticity, verticalElasticity));
	}

	GridBox *ContainerBox::AddGridBox(Count columnCount, Count expectedRowCount, int flags)
	{
		return Add(new GridBox(columnCount, expectedRowCount, flags));
	}

	FillerBox *ContainerBox::AddFillerBox(const SIZE &minimumSize, long horizontalElasticity, long verticalElasticity)
	{
		return Add(new FillerBox(minimumSize, horizontalElasticity, verticalElasticity));
	}
}
